package com.bms.hystrix.service.kzkyzl;


import com.bms.hystrix.interfaces.kzkyzl.ServiceFeignByCheck;
import com.bms.hystrix.vo.KongZhiKeYanZhiLiangGengXiShenHe;
import com.bms.hystrix.vo.KongZhiKeYanZhiLiangGengXiYuanGong;
import com.bms.hystrix.vo.KongZhiKeYanZhiLiangGengXinByIdVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Service
public class CheckService {
    @Resource
    private ServiceFeignByCheck serviceFeignByCheck;

    // 通过feign调用服务模块，如果触发熔断机制，则会调用此注解fallbackMethod定义的方法
//    @HystrixCommand(fallbackMethod = "checkError")
//    public Map check(String name) {
//        return serviceFeignByCheck.selectClient(name);
//    }

    public Map<String, Object> ChaXun(String xiangmuming,String faburen,String zhixingzhuangtai) {
        return serviceFeignByCheck.ChaXun(xiangmuming,faburen,zhixingzhuangtai);
    }

    public Map<String, Object> gengXinById(KongZhiKeYanZhiLiangGengXinByIdVo kongZhiKeYanZhiLiangGengXinByIdVo) {
        return serviceFeignByCheck.gengXinById(kongZhiKeYanZhiLiangGengXinByIdVo);
    }

    public Map<String, Object> chaXunAll() {
        return serviceFeignByCheck.chaXunAll();
    }

    public Map<String, Object> gengXinYuanGong(KongZhiKeYanZhiLiangGengXiYuanGong kongZhiKeYanZhiLiangGengXiYuanGong) {
        return serviceFeignByCheck.gengXinYuanGong(kongZhiKeYanZhiLiangGengXiYuanGong);
    }

    public Map<String, Object> gengXinShenHe(KongZhiKeYanZhiLiangGengXiShenHe kongZhiKeYanZhiLiangGengXiShenHe) {
        return serviceFeignByCheck.gengXinShenHe(kongZhiKeYanZhiLiangGengXiShenHe);
    }

    public Map<String, Object> checkError(String name) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", 500);
        map.put("msg","服务异常，请稍后重试！");
        map.put("name", name);
        return map;
    }
}
